define(function(require){
	var main = require('/static/main.js');
	require('/static/jquery.z-pager.js');
	var m = new main();
	function Cont(){
		this.Fun._init();
	}
	Cont.prototype.Fun = {
		_init:function(){
			// 初始化左边菜单
		    m.loadmenu('.cate-sceneactive',0);
		    this.getlist(100);
			this.bindEvent();
		},
		getlist:function(type){
        	$("#pager"+type).zPager({
		        url:'/sceneactive/index?type='+type,
		        pageData:12,
		        btnShow: false,
		        pageStep:8,
		        dataRender: function(data){
		        		var str = '';
		        		if(data[0] == "暂无数据"){
		        			str += '暂无活动'
		        			$('.list_'+type).css({'text-align':'center'});
		        			$('#pager'+type).hide();
		        		}else{
			        		$.each(data,function(k,v){
			               		if(type == 100){
				               		str+='<div class="col-lg-3 avtive_list_li">'
			                            str+='<div class="item">\
			                                <div class="col-lg-9 avtive_list_info">\
			                                    <h4 class="avtive_list_tit"><a href="#" >活动'+(k+1)+'：'+v.Title+'</a></h4>\
			                                    <div class="text_overflow">\
			                                        <em style="font-style: normal;">'+v.Rule+'</em>\
			                                    </div>\
			                                </div>\
			                                <div class="avtive_list_btn col-lg-3">\
			                                	<a href="/sceneactive/create?type=100&id='+v.ActTemplateId+'"><button class="btn btn-success btn-sm" style="margin-top:15px;padding:0px;width:75px;font-size:14px;background-color: #6e8cd7!important;border:none">马上创建</button></a>'
			                                	if(v.IsSelf){
			                                		str+='<a href="/sceneactive/create?type=300&id='+v.ActTemplateId+'"><button class="btn btn-success btn-sm" style="margin-top:10px;padding:0px;width:75px;font-size:14px;background-color: #00aeae!important;border:none">编辑</button></a>'
			                                	}
			                                str+='</div>\
			                            </div>\
			                        </div>'
			                    }else{
			                    	str+='<div class="col-lg-3 avtive_list_li">\
			                    			<a href="/sceneactive/detial?id='+v.ActRoomId+'">\
					                            <div class="item overflow">\
					                                <div class="col-lg-8 avtive_list_info">\
					                                    <h4 class="avtive_list_tit">房间号'+(k+1)+':'+v.Title+'<button class="btn btn-info  btn-sm ">'+v.RoomStatusName+'</button></h4>\
					                                    <div class="text_overflow">\
					                                        <em style="font-style: normal;">创建活动时间：'+m.formatTimeAll2(v.CreateTime)+'</em>\
					                                    </div>\
					                                </div>\
					                                <div class="fr show_erm">\
					                                    <img src="'+v.QrCodeSrc+'">\
					                                </div>\
					                            </div>\
				                            </a>\
				                        </div>'
			                    }  
			               	})
		        		}
		               	$('.list_'+type).html(str);

		        },
		      
		    });
		},
		bindEvent:function(){
			var _this = this;
			$('.nav-tabs li a').click(function(){
				var tabName = $(this).find('.hidden-xs').html();
				var type = parseInt($(this).attr('data-type'));
				_this.getlist(type);
				$('.page-title i').html(tabName);
			})
		}


	}
	var a = new Cont();

})